package UIFree.effects
{
	import UIFree.effects.flames.ef_flame;
	import UIFree.slideshow.ss_flameFade;
	import UIFree.slideshow.ss_slideFade;
	import UIFree.uif_Timer;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import editor.pi_source;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class effectExample extends uif_ecomponent {
		public function effectExample(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			
			var list: Array = [
				'http://content.foto.mail.ru/mail/fwadim/29/i-2014.jpg',
				'http://content.foto.mail.ru/mail/fwadim/106/i-2010.jpg',
				'http://content.foto.mail.ru/mail/fwadim/29/i-2077.jpg',
			]
			
			var rect: Rectangle = getInner();
			var index: int = 0;
			var sf: ss_slideFade = new ss_flameFade(this, ef_flames, rect.x, rect.y, rect.width, rect.height, 'effect');
			
			function loadNext(): void {
				var source: pi_source = new pi_source(This, rect.x, rect.y, rect.width, rect.height);
				source.loadSource(list[index], function(e: Event): void {
					sf.assignSource(source, {
						live				: 25,
						scale				: 1.5,
						density				: 0.8,
						flameStyle			: 'flame',
						flameSpeed			: [0, 0],
						flameLive			: 25,
						flameAtack			: 0.2,
						flameFade			: 1,
						flameClass			: ef_flame,
						flameType			: ef_flame.RECTFLAME,
						flameVolumeChange 	: [1.15, 1.15],
						flameSize			: source.width / 20
					});
					index = (index + 1) % list.length;
				});
			}
			
			new uif_Timer(3000, function(e: Event): void {
				loadNext();
			});
			loadNext();
		}
	}
}